<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head th:replace="fragment_base::head(~{::title})">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>博客-列表</title>
    <link rel="stylesheet"
          href="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.css">
    <link rel="stylesheet" href="../../static/css/common.css">
    <script src="https://cdn.jsdelivr.net/npm/jquery@3.2/dist/jquery.min.js"></script>
    <script src="../../static/js/custom.js"></script>
    <script src="../../static/js/semantic.min.js"></script>
</head>
<body>
<!--导航-->
<nav th:replace="admin/fragment_manager::menu(0)"
     class="ui inverted attached segment head-tab-padding">
    <div class="ui container">
        <!--stackable 表示可堆叠，自适应-->
        <div class="ui inverted secondary stackable menu">
            <h2 class="ui teal header item">管理后台</h2>
            <a class="menu-item item mobile-hide" href="#"><i class="teal code icon"></i>博客</a>
            <a class="menu-item item mobile-hide" href="#"><i class="teal idea icon"></i>分类</a>
            <a class="menu-item item mobile-hide" href="#"><i class="teal tags icon"></i>标签</a>
            <div class="right menu-item  mobile-hide menu">
                <div class="ui dropdown item">
                    <div class="text">
                        <img class="ui circular image"
                             src="http://xxstudy.cn/media/img/avatar_15.png"
                             style="vertical-align:middle">唐人
                    </div>
                    <i class="dropdown icon"></i>
                    <div class="menu">
                        <a href="#" class="item">注销</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!--菜单按钮-->
    <a id="menu-toggle" class=" ui black icon button bar-position mobile-show" href="#">
        <i class="sidebar icon"></i>
    </a>
</nav>
<!--列表-->
<div class="ui attached pointing menu">
    <div class="ui container">
        <div class="right menu">
            <a class="item" th:href="@{/admin/blog/create}">写博客</a>
            <a class="item teal active" th:href="@{/admin/blogs}">列表</a>
        </div>
    </div>
</div>


<!--中间内容-->
<div class="center-padding">
    <div class="ui container">
        <!--操作提示-->
        <div class="ui message" th:unless="${msg==null}"
             th:classappend="${msg.success}?'success':'error'">
            <i class="close icon"></i>
            <div class="header">提示</div>
            <p th:text="${msg.msg}">操作成功</p>
        </div>
        <div class="ui secondary segment form">
            <input type="hidden" name="page">
            <div class="inline fields">
                <!--标题框-->
                <div class="field padding-mini">
                    <input type="text" name="title" placeholder="标题">
                </div>

                <!--分类下拉框-->
                <div class="field padding-mini">
                    <div class="ui category selection dropdown">
                        <!--占位用-->
                        <input type="hidden" name="categoryId">
                        <i class="dropdown  icon"></i>
                        <div class="default text">分类</div>
                        <!--分类菜单-->
                        <div class="menu">
                            <div class="item" data-value="1" th:each="category:${categoryList}"
                                 th:data-value="${category.id}" th:text="${category.categoryName}">
                                Android
                            </div>
                            <div class="item" data-value="2">Java</div>
                        </div>
                    </div>
                    <button id="clear-btn" class="ui mini button orange">清除</button>
                </div>

                <!--checkbox-->
                <div class="field">
                    <div class="ui checkbox">
                        <input type="checkbox" id="recommend" name="recommend">
                        <label for="recommend">推荐</label>
                    </div>
                </div>

                <div class="field">
                    <div class="ui checkbox">
                        <input type="checkbox" id="published" name="published">
                        <label for="published">草稿</label>
                    </div>
                </div>

                <!--搜索按钮-->
                <div class="field">
                    <button id="search-btn" class="ui mini  teal basic button"><i
                            class="search icon"></i>搜索
                    </button>
                </div>

            </div>
        </div>

        <div id="blog-table-container">
            <!--内容区域-->
            <table th:fragment="blogList" class="ui compact teal table">
                <!--标题-->
                <thead>
                <tr>
                    <th></th>
                    <th>标题</th>
                    <th>类型</th>
                    <th>推荐</th>
                    <th>状态</th>
                    <th>更新时间</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>

                <!--内容-->
                <tr th:each="blog,list:${blogPage.content}">
                    <td th:text="${list.count}" data-label="">1</td>
                    <td th:text="${blog.title}" data-label="">Android开发技巧</td>
                    <td th:text="${blog.category?.categoryName}" data-label="">android</td>
                    <td th:text="${blog.recommendChecked}?'是':'否'" data-label="">是</td>
                    <td th:style="${blog.published}?'':'color:orange'" th:text="${blog.published}?'发布':'草稿'" data-label="">草稿</td>
                    <td th:text="${blog.updateDateTime}" data-label="">2020-11-22 20:15</td>
                    <td data-label="">
                        <a class="ui mini teal basic button" href="#"
                           th:href="@{/admin/blog/{id}/edit(id=${blog.id})}">编辑</a>
                        <a class="ui mini red basic button" href="#"
                           th:href="@{/admin/blog/{id}/delete(id=${blog.id})}">删除</a>
                    </td>
                </tr>
                </tbody>

                <!--foot-->
                <tfoot class="full-width">
                <tr>
                    <th colspan="7">
                        <div class="ui mini buttons" th:if="${blogPage.totalPages}>0">
                            <a onclick="pageGo(this)" th:unless="${blogPage.first}"
                               th:attr="data-page=${blogPage.number}-1"
                               class="ui teal basic button">上一页
                            </a>
                            <a onclick="pageGo(this)" th:unless="${blogPage.last}"
                               th:attr="data-page=${blogPage.number}+1"
                               class="ui teal basic button">下一页
                            </a>
                        </div>
                        <a href="#" th:href="@{/admin/blog/create}"
                           class="ui right floated mini teal labeled icon button"><i
                                class="add icon"></i>新增</a>
                    </th>
                </tr>
                </tfoot>
            </table>
        </div>
    </div>
</div>

<script src="../../static/js/blog-search.js" th:src="@{../js/blog-search.js}"></script>
</body>
</html>